<template>
    <h2>管理员添加</h2>
    <table>
        <tr>
            <td>用户名：</td>
            <td>
                <input type="text" v-model="Uname" />
            </td>
        </tr>
        <tr>
            <td>用户密码：</td>
            <td>
                <input type="password" v-model="Password" />
            </td>
        </tr>
        <tr>
            <td>状态：</td>
            <td>
                <input type="radio" value="true" v-model="UR_Quanxian" />启用
                <input type="radio" value="false" v-model="UR_Quanxian" />禁用
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <button @click="register">添加</button>
            </td>
        </tr>
    </table>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
const Uname = ref('');
const Password = ref('');
const UR_Quanxian = ref('');
const router = useRouter();
const register = () => {
    axios.post("http://localhost:50394/api/Role/AddRegist", {
        Uname: Uname.value,
        Password: Password.value,
        UR_Quanxian: UR_Quanxian.value
    })
        .then(res => {
            if (res.data > 0) {
                alert("注册成功");
                router.push('/ShowAdmin');
            }
            else {
                alert("注册失败");
                return;
            }
        })
        .catch(err => {
            console.log(err);
        })
}
</script>